<?php
/**
 * Load styles and scripts
 * 
 */
//include 'theme_walker.php';
include 'admin/Larch_admin.php';


function larch_scripts(){
	wp_enqueue_style('bootstrap.min', get_stylesheet_directory_uri().'/assets/css/bootstrap.min.css');
	wp_enqueue_script('bootstrap.min', get_template_directory_uri().'/assets/js/bootstrap.min.js', array('jquery'));
	if(!is_admin()){
		wp_enqueue_style('style', get_stylesheet_uri());
		wp_enqueue_script('jquery.mixitup.min',  get_template_directory_uri().'assets/js/mixitup-1.5.5/juery.mixitup.min.js',array('jquery'));
		wp_enqueue_script('larch-jquery',  get_template_directory_uri().'assets/js/larch-jquery.js',array('jquery','jquery-mixitup-min'));
	}
	
}
function larch_admin_scripts(){
	wp_enqueue_style('bootstrap.min', get_stylesheet_directory_uri().'/assets/css/bootstrap.min.css');
	wp_enqueue_script('bootstrap.min', get_template_directory_uri().'/assets/js/bootstrap.min.js', array('jquery'));
}
add_action('admin_enqueue_scripts','larch_admin_scripts');
add_action( 'wp_enqueue_scripts', 'larch_scripts' );

/**
 * Setting default content width
 * 
 */
if(!isset($content_width)){
	$content_width = 474;
}

if(!function_exists( 'larch_setup')){
	function larch_setup(){
		//load text domain
		load_theme_textdomain('larch',  get_template_directory().'/lang');
		add_theme_support('post-thumbnails');
		set_post_thumbnail_size(672,372,true);
		add_image_size('larch-full-width', 1038, 576, true);
		//register navigations
		register_nav_menus(array(
			'primary' => __('Main menu','larch'),
			'secondary' => __('Sidebar menu','larch'),
			'ternary' => ('Other navigation on a single page'),
		));
		add_theme_support('html5',array(
			'search-form','comment-form','comment-list'
		));
		add_theme_support('post-formats',array(
			'image','video','link','gallery'
		));
		add_theme_support('custom-background',array('default-color'=>'f5f5f5'));
		add_theme_support('custom-header');
	}
}
add_action('after_setup_theme','larch_setup');
if(!function_exists( 'register_navs')){
	function register_navs(){
		register_sidebar(array(
			'name'=>__('Main Navigation','larch'),
			'id'=>'pseudo-menu',
			'description'=>__('navigation','larch'),
		));
		register_sidebar(array(
			'name'=>__('Shop Sidebar','larch'),
			'id'=>'sidebar-1',
			'description'=>__('sidebar in the shop page','larch')
		));
		register_sidebar(array(
			'name'=>__('Left Sidebar','larch'),
			'id'=>'sidebar-2',
			'description'=>__('sidebar in left of the page','larch')
		));
		register_sidebar(array(
			'name'=>__('Right Sidebar','larch'),
			'id'=>'sidebar-3',
			'description'=>__('additional sidebar for the right sidebar','larch')
		));
	}
}
add_action('widgets_init','register_navs');

/**
 * Theme options
 * 
 */
add_action('admin_menu','larch_admin_menu');
if(!function_exists( 'larch_admin_menu')){
	function larch_admin_menu(){
		add_menu_page('Larch Theme Options', 'R Dan Theme Options', 'administrator', 'larch_admin_options_page', 'create_larch_admin');
	}
}
/**
 * Create Admin 
 * 
 */
function create_larch_admin(){
	Larch_admin::create_admin_page_options();
}
function init_larch_admin_options(){
	Larch_admin::add_admin_options(array(
		'larch_general_option',
		'larch_header_option',
		'larch_footer_option',
	));
	Larch_admin::del_admin_options(
			array(
				
			)
	);
	Larch_admin::create_setting_section(
			array(
				array(
					'id'=>'larch_general_option',
					'title'=>__('General Settings','larch'),
					'page'=>'larch_general_option'
				),
				array(
					'id'=>'larch_header_option',
					'title'=>__('Header Settings','larch'),
					'page'=>'larch_header_option'
				),
				array(
					'id'=>'larch_footer_option',
					'title'=>__('Footer Settings','larch'),
					'page'=>'larch_footer_option'
				),
			)
	);
	unregister_setting('larch_footer_option', 'larch_footer_option');
	Larch_admin::register_admin_settings(array(
		array('option_group'=>'larch_general_option','option'=>'larch_general_option'),
		array('option_group'=>'larch_footer_option','option'=>'larch_footer_option'),
		array('option_group'=>'larch_header_option','option'=>'larch_header_option'),
	));
	Larch_admin::create_setting_field(array(
		array('id'=>'dummy_dumdum','title'=>__('Dumdum','larch'),'page'=>'larch_general_option','section'=>'larch_general_option','args'=>array(
			'id'=>'dummy_dumdum',
			'type'=>'text',
			'option_name'=>'larch_general_option',
			'desc'=>'',
		)),
		
	));
	Larch_admin::create_spec_setting_field();
}
add_action('admin_init','init_larch_admin_options');
function general_section(){}
function header_section(){}
function footer_section(){}

function create_field($cb_args){
	Larch_admin::create_field($cb_args);
}
add_theme_support( 'woocommerce' );
add_action('larch_product_title','woocommerce_template_single_title');
add_action('larch_product_summary','woocommerce_template_single_excerpt');
add_action('larch_product_summary','woocommerce_template_single_sharing');

function create_spec_field($args){
		$larch_settings = get_option('larch_footer_option');
		
		echo "<input id ='dummy_text' name='larch_footer_option[dummy_text]' type='text' value='".$larch_settings['dummy_text']."'><label for='dummy_text'></label>";
	}